package com.cssw.fyzb.wap.controller;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.vo.TextKindListVo;
import com.cssw.fyzb.wap.model.vo.TextKindVo;
import com.cssw.fyzb.wap.service.TextService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Auther: zzf
 * @Date: 2020/12/15 11:50
 * @Description:
 */
@Api(description = "文本种类相关接口")
@RequestMapping("/text")
@Controller
public class TextController {

    private static final Logger logger = LoggerFactory.getLogger(TextController.class);

    //关于我们
    private static final String KIND_CODE_ABOUT_US = "aboutUs";
    //新手指南
    private static final String KIND_CODE_TUTORIAL = "tutorial";
    //关于福音
    private static final String KIND_CODE_GOSPEL = "gospel";
    //常见问题
    private static final String KIND_CODE_COMMON_PROBLEM="PROBLEM";

    @Autowired
    private TextService textService;

    @ApiOperation(value = "关于我们")
    @RequestMapping(value = "/aboutUs", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<TextKindListVo> aboutUs(int pageNumber, int pageSize) {
        return textService.testKindList(KIND_CODE_ABOUT_US, pageNumber, pageSize);
    }

    @ApiOperation(value = "新手指南")
    @RequestMapping(value = "/tutorial", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @ResponseBody
    public AjaxPage<TextKindListVo> tutorial(int pageNumber, int pageSize) {
        return textService.testKindList(KIND_CODE_TUTORIAL, pageNumber, pageSize);
    }

    @ApiOperation(value = "文本查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "textCode", value = "文本编码", paramType = "query", dataType = "string")
    })
    @RequestMapping(value = "/getTestKind", method = RequestMethod.GET)
    @ResponseBody
    public AjaxData<TextKindVo> getTestKind(String textCode) {
        return textService.getSysText(textCode);
    }

    @ApiOperation(value = "关于福音")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @RequestMapping(value = "/getospel", method = RequestMethod.GET)
    @ResponseBody
    public AjaxPage<TextKindListVo> getospel(int pageNumber, int pageSize) {
        return textService.testKindList(KIND_CODE_GOSPEL, pageNumber, pageSize);
    }

    @ApiOperation(value = "常见问题")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber", value = "页码, 从1开始", paramType = "query", dataType = "int", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页大小", paramType = "query", dataType = "int", required = true),

    })
    @RequestMapping(value = "/problem", method = RequestMethod.GET)
    @ResponseBody
    public AjaxPage<TextKindListVo> problem(int pageNumber, int pageSize) {
        return textService.testKindList(KIND_CODE_COMMON_PROBLEM, pageNumber, pageSize);
    }
}
